﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace Lead2012.Business
{
    public class LeadActionRepository
    {
        // Create an instance of entity
        Lead2012Entities entities = new Lead2012Entities();
        
        public LeadAction GetSingle(int id)
        {
            return (from _object in entities.LeadActions where _object.ActionId == id select _object).FirstOrDefault();
        }

        public void Create(LeadAction _object)
        {
            entities.AddToLeadActions(_object);
            entities.SaveChanges();
        }

        public void Update(LeadAction _object)
        {
            entities.SaveChanges();
        }
        public void Delete(int id)
        {
            var _object = (from _list in entities.LeadActions where _list.ActionId == id select _list).First();
            entities.DeleteObject(_object);
            entities.SaveChanges();
        }
        public void Save(LeadAction _object)
        {
            _object.EntityKey = (from LeadAction ac in entities.LeadActions where ac.ActionId == _object.ActionId select ac).FirstOrDefault().EntityKey;
            entities.SaveChanges();
        }
    }
}